<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Format EJAM tabular outputs for saving as Excel spreadsheet — table_xls_format • EJAM</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Format EJAM tabular outputs for saving as Excel spreadsheet — table_xls_format"><meta name="description" content="Used by table_xls_from_ejam()"><meta property="og:description" content="Used by table_xls_from_ejam()"><meta property="og:image" content="https://usepa.github.io/EJAM/logo.svg"></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>


    <nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">

    <a class="navbar-brand me-2" href="../index.html">EJAM</a>

    <small class="nav-text text-warning me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Released version">2.32.0</small>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item"><a class="nav-link" href="../reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
  <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
  <ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><hr class="dropdown-divider"></li>
    <li><h6 class="dropdown-header" data-toc-skip>Overview for EJAM Users</h6></li>
    <li><a class="dropdown-item" href="../articles/0_whatis.html">What is EJAM</a></li>
    <li><a class="dropdown-item" href="../articles/0_webapp.html">Using EJAM</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><h6 class="dropdown-header" data-toc-skip>For analysts using R</h6></li>
    <li><a class="dropdown-item" href="../articles/1_installing.html">Installing the EJAM R package</a></li>
    <li><a class="dropdown-item" href="../articles/2_quickstart.html">Quick Start Guide</a></li>
    <li><a class="dropdown-item" href="../articles/3_analyzing.html">Basics of Using EJAM for Analysis in RStudio</a></li>
    <li><a class="dropdown-item" href="../articles/4_advanced.html">Advanced Features</a></li>
  </ul></li>
<li class="nav-item"><a class="nav-link" href="../news/index.html">Changelog</a></li>
      </ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
 <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="../search.json"></form></li>
      </ul></div>


  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.svg" class="logo" alt=""><h1>Format EJAM tabular outputs for saving as Excel spreadsheet</h1>
      <small class="dont-index">Source: <a href="https://github.com/USEPA/EJAM/blob/HEAD/R/table_xls_format.R" class="external-link"><code>R/table_xls_format.R</code></a></small>
      <div class="d-none name"><code>table_xls_format.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Used by table_xls_from_ejam()</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">table_xls_format</span><span class="op">(</span></span>
<span>  <span class="va">overall</span>,</span>
<span>  <span class="va">eachsite</span>,</span>
<span>  longnames <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  formatted <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  bybg <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  plot_distance_by_group <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  summary_plot <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  plotlatest <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  plotfilename <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  mapadd <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  community_reportadd <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  report_map <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  community_image <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  ok2plot <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  analysis_title <span class="op">=</span> <span class="st">"EJAM analysis"</span>,</span>
<span>  buffer_desc <span class="op">=</span> <span class="st">"Selected Locations"</span>,</span>
<span>  radius_or_buffer_in_miles <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  radius_or_buffer_description <span class="op">=</span></span>
<span>    <span class="st">"Miles radius of circular buffer (or distance used if buffering around polygons)"</span>,</span>
<span>  notes <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  custom_tab <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  custom_tab_name <span class="op">=</span> <span class="st">"other"</span>,</span>
<span>  heatmap_colnames <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  heatmap_cuts <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">80</span>, <span class="fl">90</span>, <span class="fl">95</span><span class="op">)</span>,</span>
<span>  heatmap_colors <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"yellow"</span>, <span class="st">"orange"</span>, <span class="st">"red"</span><span class="op">)</span>,</span>
<span>  heatmap2_colnames <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  heatmap2_cuts <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1.009</span>, <span class="fl">2</span>, <span class="fl">3</span><span class="op">)</span>,</span>
<span>  heatmap2_colors <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"yellow"</span>, <span class="st">"orange"</span>, <span class="st">"red"</span><span class="op">)</span>,</span>
<span>  hyperlink_colnames <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"EJScreen Report"</span>, <span class="st">"EJScreen Map"</span>, <span class="st">"ECHO report"</span><span class="op">)</span>,</span>
<span>  graycolnames <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  narrowcolnames <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  graycolor <span class="op">=</span> <span class="st">"gray"</span>,</span>
<span>  narrow6 <span class="op">=</span> <span class="fl">6</span>,</span>
<span>  testing <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  updateProgress <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  launchexcel <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  saveas <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  ejscreen_ejam_caveat <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  <span class="va">...</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>


<dl><dt id="arg-overall">overall<a class="anchor" aria-label="anchor" href="#arg-overall"></a></dt>
<dd><p>table to save in one tab, from ejamit()$results_overall, EJAM analysis of indicators overall (one row),
but if entire output of ejamit() is passed as if it were overall, function figures out eachsite, etc.</p></dd>


<dt id="arg-eachsite">eachsite<a class="anchor" aria-label="anchor" href="#arg-eachsite"></a></dt>
<dd><p>table to save in one tab, from ejamit()$results_bysite, EJAM analysis site by site (one row per site)</p></dd>


<dt id="arg-longnames">longnames<a class="anchor" aria-label="anchor" href="#arg-longnames"></a></dt>
<dd><p>vector of indicator names to display in Excel table</p></dd>


<dt id="arg-formatted">formatted<a class="anchor" aria-label="anchor" href="#arg-formatted"></a></dt>
<dd><p>optional table to save in one tab, from ejamit()$results_overall, EJAM analysis overall in different format</p></dd>


<dt id="arg-bybg">bybg<a class="anchor" aria-label="anchor" href="#arg-bybg"></a></dt>
<dd><p>Optional large table of details of each block group that is only needed to analyze distances by group.</p></dd>


<dt id="arg-plot-distance-by-group">plot_distance_by_group<a class="anchor" aria-label="anchor" href="#arg-plot-distance-by-group"></a></dt>
<dd><p>logical, whether to try to add a plot of mean distance by group.
This requires that bybg be provided as a parameter input to this function.</p></dd>


<dt id="arg-summary-plot">summary_plot<a class="anchor" aria-label="anchor" href="#arg-summary-plot"></a></dt>
<dd><p>optional plot object passed from EJAM shiny app to save in 'Plot' sheet of Excel table</p></dd>


<dt id="arg-plotlatest">plotlatest<a class="anchor" aria-label="anchor" href="#arg-plotlatest"></a></dt>
<dd><p>optional logical. If TRUE, the most recently displayed plot (prior to this function being called) will be inserted into a tab called plot2</p></dd>


<dt id="arg-plotfilename">plotfilename<a class="anchor" aria-label="anchor" href="#arg-plotfilename"></a></dt>
<dd><p>the full path including name of .png file to insert</p></dd>


<dt id="arg-mapadd">mapadd<a class="anchor" aria-label="anchor" href="#arg-mapadd"></a></dt>
<dd><p>logical optional - try to include a map of the points</p></dd>


<dt id="arg-community-reportadd">community_reportadd<a class="anchor" aria-label="anchor" href="#arg-community-reportadd"></a></dt>
<dd><p>logical provided by shiny app to specify whether to include community report image</p></dd>


<dt id="arg-report-map">report_map<a class="anchor" aria-label="anchor" href="#arg-report-map"></a></dt>
<dd><p>leaflet map object passed from Shiny app to display in 'Map' sheet</p></dd>


<dt id="arg-community-image">community_image<a class="anchor" aria-label="anchor" href="#arg-community-image"></a></dt>
<dd><p>image of community report provided by shiny app to include in spreadsheet</p></dd>


<dt id="arg-ok-plot">ok2plot<a class="anchor" aria-label="anchor" href="#arg-ok-plot"></a></dt>
<dd><p>can set to FALSE to prevent plots from being attempted, while debugging</p></dd>


<dt id="arg-analysis-title">analysis_title<a class="anchor" aria-label="anchor" href="#arg-analysis-title"></a></dt>
<dd><p>optional title passed from Shiny app to 'Notes' sheet</p></dd>


<dt id="arg-buffer-desc">buffer_desc<a class="anchor" aria-label="anchor" href="#arg-buffer-desc"></a></dt>
<dd><p>optional description of buffer used in analysis, passed to 'Notes' sheet</p></dd>


<dt id="arg-radius-or-buffer-in-miles">radius_or_buffer_in_miles<a class="anchor" aria-label="anchor" href="#arg-radius-or-buffer-in-miles"></a></dt>
<dd><p>If provided, miles buffer distance (from polygon or from point if circular buffers)</p></dd>


<dt id="arg-radius-or-buffer-description">radius_or_buffer_description<a class="anchor" aria-label="anchor" href="#arg-radius-or-buffer-description"></a></dt>
<dd><p>optional text saying if distance is radius or polygon buffer, passed to 'Notes' sheet</p></dd>


<dt id="arg-notes">notes<a class="anchor" aria-label="anchor" href="#arg-notes"></a></dt>
<dd><p>Text of additional notes to put in the notes tab, optional vector of character elements pasted in as one line each.</p></dd>


<dt id="arg-custom-tab">custom_tab<a class="anchor" aria-label="anchor" href="#arg-custom-tab"></a></dt>
<dd><p>optional table to put in an extra tab</p></dd>


<dt id="arg-custom-tab-name">custom_tab_name<a class="anchor" aria-label="anchor" href="#arg-custom-tab-name"></a></dt>
<dd><p>optional name of optional custom_tab</p></dd>


<dt id="arg-heatmap-colnames">heatmap_colnames<a class="anchor" aria-label="anchor" href="#arg-heatmap-colnames"></a></dt>
<dd><p>optional vector of colnames to apply heatmap colors, defaults to percentiles</p></dd>


<dt id="arg-heatmap-cuts">heatmap_cuts<a class="anchor" aria-label="anchor" href="#arg-heatmap-cuts"></a></dt>
<dd><p>vector of values to separate heatmap colors, between 0-100 for percentiles</p></dd>


<dt id="arg-heatmap-colors">heatmap_colors<a class="anchor" aria-label="anchor" href="#arg-heatmap-colors"></a></dt>
<dd><p>vector of color names for heatmap bins, same length as
heatmap_cuts, where first color is for those &gt;= 1st cutpoint, but &lt;2d,
second color is for those &gt;=2d cutpoint but &lt;3d, etc.</p></dd>


<dt id="arg-heatmap-colnames">heatmap2_colnames<a class="anchor" aria-label="anchor" href="#arg-heatmap-colnames"></a></dt>
<dd><p>like heatmap_colnames but for ratios by default</p></dd>


<dt id="arg-heatmap-cuts">heatmap2_cuts<a class="anchor" aria-label="anchor" href="#arg-heatmap-cuts"></a></dt>
<dd><p>like heatmap_cuts but for ratios by default</p></dd>


<dt id="arg-heatmap-colors">heatmap2_colors<a class="anchor" aria-label="anchor" href="#arg-heatmap-colors"></a></dt>
<dd><p>like heatmap_colors but for ratios</p></dd>


<dt id="arg-hyperlink-colnames">hyperlink_colnames<a class="anchor" aria-label="anchor" href="#arg-hyperlink-colnames"></a></dt>
<dd><p>names of which to treat as URLs that should be hyperlinks</p></dd>


<dt id="arg-graycolnames">graycolnames<a class="anchor" aria-label="anchor" href="#arg-graycolnames"></a></dt>
<dd><p>which columns to deemphasize</p></dd>


<dt id="arg-narrowcolnames">narrowcolnames<a class="anchor" aria-label="anchor" href="#arg-narrowcolnames"></a></dt>
<dd><p>which column numbers to make narrow</p></dd>


<dt id="arg-graycolor">graycolor<a class="anchor" aria-label="anchor" href="#arg-graycolor"></a></dt>
<dd><p>color used to deemphasize some columns</p></dd>


<dt id="arg-narrow-">narrow6<a class="anchor" aria-label="anchor" href="#arg-narrow-"></a></dt>
<dd><p>how narrow</p></dd>


<dt id="arg-testing">testing<a class="anchor" aria-label="anchor" href="#arg-testing"></a></dt>
<dd><p>optional for testing only</p></dd>


<dt id="arg-updateprogress">updateProgress<a class="anchor" aria-label="anchor" href="#arg-updateprogress"></a></dt>
<dd><p>optional Shiny progress bar to update during formatting</p></dd>


<dt id="arg-launchexcel">launchexcel<a class="anchor" aria-label="anchor" href="#arg-launchexcel"></a></dt>
<dd><p>Set to TRUE to have this function launch Excel immediately, showing the final workbook created here.</p></dd>


<dt id="arg-saveas">saveas<a class="anchor" aria-label="anchor" href="#arg-saveas"></a></dt>
<dd><p>If not NULL, and a valid path with filename.xlsx is provided,
the workbook will be saved locally at that path and name. Warning: it will overwrite an existing file.</p></dd>


<dt id="arg-ejscreen-ejam-caveat">ejscreen_ejam_caveat<a class="anchor" aria-label="anchor" href="#arg-ejscreen-ejam-caveat"></a></dt>
<dd><p>optional text if you want to change this in the notes tab</p></dd>


<dt id="arg--">...<a class="anchor" aria-label="anchor" href="#arg--"></a></dt>
<dd><p>other params passed along to <code><a href="https://rdrr.io/pkg/openxlsx/man/writeData.html" class="external-link">openxlsx::writeData()</a></code></p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    <p>a workbook, ready to be saved in spreadsheet format, with tabs like "Overall" and "Each Site"</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>Already took and put here most or all of code from table_xls_format() or table_xls_format_api()</p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p><code><a href="table_xls_from_ejam.html">table_xls_from_ejam()</a></code></p></div>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="kw">if</span> <span class="op">(</span><span class="cn">FALSE</span><span class="op">)</span> <span class="op">{</span> <span class="co"># \dontrun{</span></span>
<span>  <span class="fu">table_xls_format</span><span class="op">(</span></span>
<span>    <span class="va">testoutput_ejamit_100pts_1miles</span><span class="op">$</span><span class="va">results_overall</span>, </span>
<span>    <span class="va">testoutput_ejamit_100pts_1miles</span><span class="op">$</span><span class="va">results_bysite</span>,</span>
<span>    saveas <span class="op">=</span>  <span class="st">"out1.xlsx"</span><span class="op">)</span></span>
<span> <span class="co"># can just pass the whole results of ejamit(), for convenience</span></span>
<span> <span class="va">wb</span> <span class="op">&lt;-</span> <span class="fu">table_xls_format</span><span class="op">(</span><span class="va">testoutput_ejamit_100pts_1miles</span><span class="op">)</span></span>
<span> <span class="fu">openxlsx</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/openxlsx/man/saveWorkbook.html" class="external-link">saveWorkbook</a></span><span class="op">(</span><span class="va">wb</span>, file <span class="op">=</span> <span class="st">"out2.xlsx"</span><span class="op">)</span></span>
<span><span class="op">}</span> <span class="co"># }</span></span>
<span></span></code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p>US EPA 2025</p>
</div>

<div class="pkgdown-footer-right">
  <p>EJAM Version 2.32.0</p>
</div>

    </footer></div>





  </body></html>

